var minWindow = function (s, t) {
    let left = 0;
    let right = 0;
    let min = Infinity;
    let arr = [];
    while (right < s.length) {
        if (arr.length >= t.length) {
            if (t.indexOf(s[right]) !== -1) {
                arr.push(s[right]);
                right++;

            } else {
                if (t.indexOf(s[left]) !== -1) {
                    arr.splice(arr.indexOf(s[left]), 1);

                }
                left++;
            }
            if (arr.length === t.length) {
                min = Math.min(min, right - left);
            }
        }else{
            right++;
        }
    }
    return min === Infinity ? "" : s.slice(left, left + min);
};

console.log(minWindow("ADOBECODEBANC", "ABC"));